include make.defs.local

### for SW5
#INC_HOME=/usr/sz/swcc/sw3gcc-binary/include
### for SW9
INC_HOME=/usr/sw/swgcc/swgcc710-tools-9A/usr/lib_for_gcc/include
CFLAGS=-mieee -mftz -msimd -fgnu89-inline -fpermissive $(EXTRA_FLAGS)
CFLAGS+=-faddress_align=64

LIBFLAGS=-lstdc++ -lm -lm_slave

EXTRA_FLAGS=-D_DAG_TIME -D_EXEC_TIME -I${INC_HOME} 
#EXTRA_FLAGS+= -DACEMESH_PROFILING_CLASSIFY
#CFLAGS+=-D_RETURN_VERTICAL  #-DOLD_STYLE #-DUSE_PRIORITY_QUEUE

# imcomplete tiles at both ends when initoffset!=0. there are some bugs, so set this switch for debug
#EXTRA_FLAGS+=-DOLDOFFSET

#EXTRA_FLAGS+=-DLOCAL_MULTI_PRIORI -DLOCAL_MULTI_SIZE=7

#EXTRA_FLAGS+= -DWITHOUT_CONCUR_OVER_STATE

EXTRA_FLAGS+= -DLOCAL_FLAG   # for status, necessary 
EXTRA_FLAGS+= -DLOCAL_FLAG_M2S

#EXTRA_FLAGS+=-DIMMEDIA_UPDATE             #enable by default, do not close
EXTRA_FLAGS+=-DNO_END_TASK_LIST           #enable by default, get_end_tasks via scanning hashmap, do not close
EXTRA_FLAGS+=-DLIGHT_BUILD_GRAPH
#EXTRA_FLAGS+=-DLIGHT_BUILD_GRAPH1        #disable by default, useless
#EXTRA_FLAGS+=-DLIGHT_BUILD_GRAPH2        #disable by default, useless
EXTRA_FLAGS+=-DLIGHT_BUILD_GRAPH_SWITCH   #enable by default, do not close
#EXTRA_FLAGS+=-DLOW_COUPLING_GRAPH
#EXTRA_FLAGS+=-DCLUSTERING
#EXTRA_FLAGS+=-DTEMP_NEED_SPAWN
#EXTRA_FLAGS+=-DSCAN_NEED_SPAWN
#EXTRA_FLAGS+=-DFAKE_CONCURRENT_GRAPH     #temp configure, disable by default
#EXTRA_FLAGS+=-DIF_CON_UPDATE

#EXTRA_FLAGS+=-DEMP_PUT_FULL_PROF

#EXTRA_FLAGS+=-DFINE_PROF1
#EXTRA_FLAGS+=-DFINE_PROF2                 #FINE profiling, only for hash.find
#EXTRA_FLAGS+=-DFINE_PROF3                 #FINE profiling, only for hash.insert

##for SW9 CONCURRENT_CONSTRUCT_GRAPH
EXTRA_FLAGS+=-DMULTI_SPAWN
#EXTRA_FLAGS+=-DEMP_PROFILING
#EXTRA_FLAGS+=-DGS_AGENT  #only for SW9 EMP-C,too slow
#EXTRA_FLAGS+=-DEMP_LOCK
#EXTRA_FLAGS+=-DAGENT_SUCC
#EXTRA_FLAGS+=-DSIMD_RECV
#EXTRA_FLAGS+=-DSIMD_POP
EXTRA_FLAGS+=-DBLOCK_AGENT
EXTRA_FLAGS+=-DSPEIO
#EXTRA_FLAGS+=-DUNBLOCK_AGENT

ifeq ($(GRAPH_STRUCTURE),FAT)
CFLAGS+= -DFAT_TDG
CFLAGS+= -DFLAT_CONSTRUCT_HELEPR
# CFLAGS+=-DNEST_UNIQUE_TUPLES  #disable by default, open
# CFLAGS+= -DSLAVE_BUILD   #slave build nested
#CFLAGS+= -DMASTER_BUILD   #TODO master build nested
ifeq ($(USE_SLAVE_HELPER), true)
# CFLAGS+= -DSLAVE_CONSTRUCT_HELEPR
# CFLAGS+= -DMULZTI_CORE_C
# CFLAGS+= -DDISTRIBUTE_TOP
# CFLAGS+= -DDISTRUBUTE_HASH
endif
endif



EXTRA_FLAGS+=-DBIG_CR_REGION

#EXTRA_FLAGS+=-DMERGE_SAME_ADDR

#EXTRA_FLAGS+= -DDOUBLE_FUNC

#EXTRA_FLAGS+= -DSEG_BUFF #-DARRAY_STACK
EXTRA_FLAGS+= -DN_SLAVE_AGENT=1
#EXTRA_FLAGS+= -DLOCAL_SEG    #
#EXTRA_FLAGS+= -DMMEM_SEG
#EXTRA_FLAGS+= -DTWIN_SEG

#EXTRA_FLAGS+= -DTEMP_MODI    # for general task, it's necessory
#EXTRA_FLAGS+= -DTEMP_MODI_MASTER  # it's necessory for master support
#EXTRA_FLAGS+= -DTEMP_MODI_MPI     # it's necessory for mpi non-blocking 

#EXTRA_FLAGS+= -DTEMP_AFFI
#EXTRA_FLAGS+= -DINIT_OFFSET
#EXTRA_FLAGS+= -DAGENT_RANDOM_STEALING #only for main memory concurrent queue
#EXTRA_FLAGS+= -DCOPY_OLD

#EXTRA_FLAGS+= -DTEMP_ASSERT  #only for DEBUG, adding some extra checks


#EXTRA_FLAGS+= -DASYN_INSERT_REMOTE_Q


CFLAGS+= $(EXTRA_FLAGS)
#CFLAGS += -DMUTEX_BASIC

#CFLAGS += -DUSE_COMPOSITE_TASK 
#CFLAGS += -DTEMP_NESTED     # for static task_graph object
#CFLAGS += -DTEMP_DEBUG
CFLAGS += -DAGENT_COMPU
#CFLAGS += -DTEMP_M2L

#target machine and compiler env.
ifeq ($(TARGET), SW3)
CC = swCC 
cc = swcc
cc_slave = sw3cc
HEAD_DEFINE += \#define TARG_SW3\n
CFLAGS += -DTARG_SW3
else  
  ifeq ($(TARGET), SW9) #SW9
#PATH_HOME=/usr/sw/swgcc/swgcc710-tools-9A-980/usr/bin/
#PATH_HOME=/usr/sw/swgcc/swgcc710-tools-9A-910/usr/bin/
    CC=$(PATH_HOME)swg++  -mhost
    cc = $(PATH_HOME)swgcc -mhost -fgnu89-inline
    cc_slave = $(PATH_HOME)swgcc  -mslave -fgnu89-inline 
    HEAD_DEFINE += \#define TARG_SW9\n
    CFLAGS+= -DTARG_SW9
  else
    CC = sw5cc -host 
    cc = sw5cc -host 
    #cc_slave = sw5cc.old  #-slave
    cc_slave = sw5cc -slave -msimd
    HEAD_DEFINE += \#define TARG_SW5\n
    CFLAGS += -DTARG_SW5
  endif
endif

#define in head file
#the many flag for function
HEAD_DEFINE = 

ifeq ($(SCHEDULER), AceMesh_scheduler)
CFLAGS+= -DACEMESH_SCHEDULER
HEAD_DEFINE += \#define ACEMESH_SCHEDULER\n
else
	ifeq ($(SCHEDULER), dynamic_scheduler)
	CFLAGS+= -DDYNAMIC_SCHEDULER
	HEAD_DEFINE += \#define DYNAMIC_SCHEDULER\n
	endif
endif

ifeq ($(CPU_BIND), true)
CFLAGS+= -DCPUBIND
HEAD_DEFINE += \#define CPUBIND\n
endif

ifeq ($(VERBOSE), true)
CFLAGS+= -DVERB
HEAD_DEFINE += \#define VERB\n
endif

ifeq ($(DOUBLE_FUNC), true)
CFLAGS+= -DDOUBLE_FUNC
endif

ifeq ($(MQUEUE), Hq_circular)
CFLAGS+= -D_CIRCULAR_QUEUE -D_LDMQ -D_BULKTRANS -DPENDING_TASK_NUM=1000 -DSUCC_BATCH 
#CFLAGS+= -D_CIRCULAR_QUEUE -DPENDING_TASK_NUM=1000 -DSUCC_BATCH 
#HEAD_DEFINE += \#define _CIRCULAR_QUEUE\n \#define _BULKTRANS\n \#define _LDMQ\n
#	ifeq ($(BULKTRANS), true)
#	CFLAGS+= -D_BULKTRANS -D_LDMQ
#	HEAD_DEFINE += \#define _BULKTRANS\n
#	HEAD_DEFINE += \#define _LDMQ\n
#	endif
else
	ifeq ($(MQUEUE), Hq_dyn)
	CFLAGS+= -D_SERIAL_QUEUE -D_LDMQ 
		ifeq ($(EMP_RANDOM_STEALING), true)
		CFLAGS+= -DEMP_RANDOM_STEALING
			ifeq ($(EMP_STEALING_PROF), true)
			CFLAGS+= -DEMP_STEALING_PROF
			endif
		endif

		ifeq ($(Hq_dyn_SUCC_BATCH), true) 
		CFLAGS+= -DPENDING_TASK_NUM=1000 -DSUCC_BATCH #-DSUCC_BATCH_V1 
		endif
		ifeq ($(ASYN_SPAWN), REMOTE)
		CFLAGS+= -DASYN_INSERT_Q
        CFLAGS+= -DASYN_INSERT_REMOTE_Q
            ifeq ($(EMP_Mqueue_RANDOM_STEALING), true)
            CFLAGS+= -DEMP_D_RANDOM_STEALING
            endif
		else 
		    ifeq ($(ASYN_SPAWN), LOCAL)
			CFLAGS+= -DASYN_INSERT_Q
			CFLAGS+= -DASYN_INSERT_LOCAL_Q
                ifeq ($(EMP_Mqueue_RANDOM_STEALING), true)
                CFLAGS+= -DEMP_D_RANDOM_STEALING
                endif			
			else
			    ifeq ($(ASYN_SPAWN), WAITTING)
				CFLAGS+= -DASYN_INSERT_Q
				CFLAGS+= -DDELAYED_SEND
				endif
			endif
        endif
#	HEAD_DEFINE += \#define _SERIAL_QUEUE\n \#define _LDMQ\n
	else
		ifeq ($(MQUEUE), EMP_QUEUE)
			CFLAGS+= -DEMP_QUEUE
			ifeq ($(EMP_QUEUE_MULTI_PUSH), true)
				CFLAGS+= -DMULTI_PUSH
			endif

			ifeq ($(EMP_QUEUE_MULTI_POP), true)
				CFLAGS+= -DMULTI_POP
			endif

			ifeq ($(EMP_QUEUE_PROFILING), true)
				CFLAGS+= -DEMP_QUEUE_PROFILING
			endif

			ifeq ($(EMP_QUEUE_LOC), LDM_QUEUE)
				CFLAGS+= -DLDM_QUEUE
			else
				ifeq ($(EMP_QUEUE_LOC), HIER_QUEUE_LIFO)
					CFLAGS+= -DHIER_QUEUE_LIFO
				endif

				ifeq ($(EMP_QUEUE_LOC), HIER_QUEUE_FIFO)
					CFLAGS+= -DHIER_QUEUE_FIFO
				endif

				ifeq ($(EMP_QUEUE_LOC), MEM_CON_QUEUE)
					CFLAGS+= -DEMP_CONCURRENT_Q
				endif
			endif

			ifeq ($(EMP_QUEUE_GS_MSG_CNT), true)
				CFLAGS+= -DGS_MSG_CNT
			endif

			ifeq ($(EMP_MASTER_SUPPORT), true)
				CFLAGS+= -DEMP_MASTER
			endif

			ifeq ($(EMP_MAIN_PUSH_PROFILING), true)
				CFLAGS+= -DEMP_MAIN_PUSH_PROFILING
			endif
			
			ifeq ($(EMP_QUEUE_WORKER_CONF), true)
				CFLAGS+= -DEMP_WORKER_CONF
			endif

			ifeq ($(EMP_QUEUE_POP_REC), true)
				CFLAGS+= -DEMP_POP_REC
			endif
#		else
#            ifeq ($(Mqueue_RANDOM_STEALING), true)
#                CFLAGS+= -DCONCUR_Q_RANDOM_STEALING 
#            endif
        endif
	endif
endif

ifeq ($(THREADS_IDLING_PROF), true)
	CFLAGS+= -DTHREADS_IDLING_PROF
endif

ifeq ($(SYNC), MUTEX-SHM)
	CFLAGS+= -Dmutex_lock
else
	ifeq ($(SYNC), MUTEX-BASIC)
		CFLAGS += -Dmutex_lock -DMUTEX_BASIC
	endif

	ifeq ($(SYNC), MLOCK)
		CFLAGS += -DMLOCK
	endif
endif

ifeq ($(SCHEDULER_FORM), DISTRIBUTED)
	CFLAGS+= -DDISTRIBUTED_SCHEDULER
    ifeq ($(Mqueue_RANDOM_STEALING), true)
        CFLAGS+= -DCONCUR_Q_RANDOM_STEALING 
    endif
else
	ifeq ($(SCHEDULER_FORM), CENTRALIZED_FIFO)
		CFLAGS+= -DCENTRAL_FIFO
	endif
endif

ifeq ($(THREAD_TRACE),level_2)
    CFLAGS+= -DTHREAD_TRACE
else  
    ifeq ($(THREAD_TRACE),level_1)
	CFLAGS+= -DTHREAD_TRACE -DTHREAD_TRACE_LEVEL_1
	endif
endif

ifeq ($(PRIORITY_QUEUE),true)
  CFLAGS+= -DUSE_PRIORITY_QUEUE
endif

ifeq ($(LDMQ), true)
CFLAGS+= -D_LDMQ
HEAD_DEFINE += \#define _LDMQ\n
endif

ifeq ($(SPAWN), spawn)
CFLAGS += -D_SPAWN
HEAD_DEFINE += \#define _SPAWN\n
endif

ifeq ($(NESTED), true)
CFLAGS += -DUSE_COMPOSITE_TASK
#CFLAGS += -DTEMP_NESTED
#CFLAGS += -DAGENT_COMPU
#CFLAGS += -DTEMP_M2L
endif

#the Macro for PARTITION task_graph
ifeq ($(SUPPORT_PARTITION),AUTO)
CFLAGS+= -DAUTO_PARTITION
HEAD_DEFINE += \#define AUTO_PARTITION\n
else 
	ifeq ($(SUPPORT_PARTITION),MANUAL)
	CFLAGS+= -DSUPPORT_PARTITION
	HEAD_DEFINE += \#define SUPPORT_PARTITION\n
	endif
endif

ifeq ($(BLACKNODE_TOPO), true)
CFLAGS+= -D_BLACKROW
HEAD_DEFINE += \#define _BLACKROW\n
else
	ifeq ($(BLACKNODE_TOPO), redblack)
	CFLAGS+= -D_REDBLACK
	HEAD_DEFINE += \#define _REDBLACK\n
	endif
endif

ifeq ($(MAP), COLM)
CFLAGS+= -D_MAP_COLM
HEAD_DEFINE += \#define _MAP_COLM\n
else
	ifeq ($(MAP), ROWS)
	CFLAGS+= -D_MAP_ROWS
	HEAD_DEFINE += \#define _MAP_ROWS\n
	endif
endif

ifeq ($(SWF),true)
  CFLAGS+= -DSWF
else
  CFLAGS+= #-DSWF
endif

ifeq ($(USE_SIMD),true)
  CFLAGS+= -DUSE_SIMD
endif

ifeq ($(OLD_STYLE),true)
  CFLAGS+= -DOLD_STYLE
endif

ifeq ($(SPECIFY_END_TASKS),true)
  CFLAGS+= -DSPECIFY_END_TASKS
  HEAD_DEFINE += \#define SPECIFY_END_TASKS\n
endif

ifeq ($(AUTO_AFFINITY),ALL_CYCLIC)
  CFLAGS+= -DAUTO_AFFINITY -DALL_CYCLIC
else
  CFLAGS+= -DAUTO_AFFINITY
endif


#MASTER_CORE TASK related
ifeq ($(MASTER_SURPPORT),true)
  CFLAGS+= -DMASTER
  HEAD_DEFINE += \#define MASTER\n
  #MPI_SURPPORT related
  ifeq ($(MPI_SURPPORT),true)
    CFLAGS+= -DMPI_SURPPORT
    HEAD_DEFINE += \#define MPI_SURPPORT\n
  endif
endif

ifeq ($(ACEMESH_PROFILING),true)
CFLAGS+= -DACEMESH_SCHEDULER_PROFILING -DACEMESH_TIME
HEAD_DEFINE += \#define ACEMESH_SCHEDULER_PROFILING\n\#define ACEMESH_TIME\n
  ifeq ($(ACEMESH_PROFILING_INST),true)
  CFLAGS+=-DACEMESH_PROFILING_INST
  endif
  ifeq ($(ACEMESH_PROFILING_SUCC),true)
  CFLAGS+=-DACEMESH_PROFILING_SUCC
  endif
endif

ifeq ($(ACEMESH_PROFILING_NPARA),true)
CFLAGS+= -DACEMESH_TIME -DACEMESH_PARA
HEAD_DEFINE += \#define ACEMESH_TIME\n\#define ACEMESH_PARA\n
endif

ifeq ($(ACEMESH_GRAPH_BUILD_PROFILING),true)
CFLAGS+= -DACEMESH_GRAPH_BUILD_PROFILING -DACEMESH_TIME
else
    ifeq ($(ACEMESH_GRAPH_BUILD_PROFILING),COARSE)
    CFLAGS+= -DACEMESH_GRAPH_BUILD_PROFILING -DACEMESH_TIME -DCOARSE_PROF
    else
        ifeq ($(ACEMESH_GRAPH_BUILD_PROFILING),FINE)
        CFLAGS+= -DACEMESH_GRAPH_BUILD_PROFILING -DACEMESH_TIME -DCOARSE_PROF -DFINE_PROF
        endif
    endif
endif

ifeq ($(TASK_LIFETIME_PROFILING), true)
CFLAGS+= -DTASK_LIFETIME_PROFILING
endif

ifeq ($(MAIN_MUTEX_PROFILING), true)
CFLAGS+= -DMAIN_MUTEX_PROFILING
endif

ifeq ($(PAPI_PERFORMANCE),true)
CFLAGS+= -DACEMESH_PERFORMANCE -I$(PAPI_DIR)/include/ 
HEAD_DEFINE += \#define ACEMESH_PERFORMANCE\n
endif

ifeq ($(CONCURRENT_CONSTRUCT_GRAPH),true)
CFLAGS+= -DCONCURRENT_CONSTRUCT_GRAPH
endif

ifeq ($(PARALLEL_LEVEL),NO_PARALLEL)
CFLAGS+= -DNO_PARALLEL
HEAD_DEFINE += \#define NO_PARALLEL\n 
else
CFLAGS+= -DFOR_PARALLEL
HEAD_DEFINE += \#define FOR_PARALLEL\n 
endif

ifeq ($(DATA_RACE_TRACE),true)
CFLAGS+= -DDATA_RACE_TRACE
HEAD_DEFINE += \#define DATA_RACE_TRACE\n 
endif

ifeq ($(Profiling),true)
CFLAGS+= -DTBB_DEBUG -DTBB_USE_THREADING_TOOLS
endif

ifeq ($(MIC),true)
CFLAGS+= -mmic 
endif

ifeq ($(Profiling),true)
LIBFLAGS+= -ltbb_debug
endif

ifeq ($(LDM_MANAGEMENT),true)
CFLAGS += -DLDMM
endif

ifeq ($(DEBUG),true)
CFLAGS+= -g -O0 -DDEBUG
else
CFLAGS+= -O3
endif

ifeq ($(MEMORY_POOL),true)
CFLAGS += -DMEMORY_POOL
HEAD_DEFINE += \#define MEMORY_POOL\n
endif

ifeq ($(DEBUG_GRAPH),true)
CFLAGS+= -DDEBUG_GRAPH -D_EXEC_TIME -DMERGE_SAME_ADDR -DSAVE_RW_INFO -DACEMESH_SCHEDULER #-DACEMESH_TIME 
LIBFLAGS+= -ltbb_debug 
HEAD_DEFINE += \#define DEBUG_GRAPH\n \#define SAVE_RW_INFO\n 
endif

ifeq ($(ACEMESH_THREAD_GROUP),true)
CFLAGS += -D__ACEMESH_THREAD_GROUP
HEAD_DEFINE += \#define __ACEMESH_THREAD_GROUP\n
endif

ifeq ($(REUSE_GRAPH),true)
CFLAGS += -DREUSE_GRAPH
HEAD_DEFINE += \#define REUSE_GRAPH\n
endif

ifeq ($(ACEMESH_LOG),true)
CFLAGS += -DACEMESH_LOG
endif


source_h                     = aceMesh_runtime.h
source_aceMesh_cpp           = aceMesh_runtime.cpp 

source_aceMesh_task_cpp      = aceMesh_task.c
source_aceMesh_task_slave_cpp = aceMesh_task_slave.c
source_aceMesh_task_h        = aceMesh_task.h 
source_task_dag_graph_cpp    = task_dag_graph.cpp 
source_task_dag_graph_h      = task_dag_graph.h 

#source_concurrent_aceMesh_task_cpp      = concurrent_aceMesh_task.cpp 
#source_concurrent_aceMesh_task_h        = concurrent_aceMesh_task.h 
#source_concurrent_task_dag_graph_cpp    = concurrent_task_dag_graph.cpp 
#source_concurrent_task_dag_graph_h      = concurrent_task_dag_graph.h 

source_addr_area_manager_h   = addr_area_manager.h 
source_addr_area_manager_cpp = addr_area_manager.cpp 
source_dag_graph_check_h     = dag_graph_check.h 
source_dag_graph_check_cpp   = dag_graph_check.cpp 


#OBJECTS = aceMesh_runtime.o  ci_task.o aceMesh_composite_task.o aceMesh_clang.o aceMesh_clang_slave.o addr_area_manager.o \
#		  affinity_id_generator.o disjoin_set.o aceMesh_utils.o  dag_graph_check.o \
#		  trace_out_slave.o acelog.o affinity_id_generator_range.o
OBJECTS = aceMesh_runtime.o  ci_task.o aceMesh_composite_task.o aceMesh_clang.o aceMesh_clang_slave.o addr_area_manager.o\
		  affinity_id_generator.o aceMesh_utils.o  aceMesh_utils_slave.o dag_graph_check.o \
		  trace_out_slave.o acelog.o affinity_id_generator_range.o hashtable.o hashtable_slave.o ci_task_slave.o

ifeq ($(TARGET), SW5)
OBJECTS += dma_reuse_slave.o
endif

ifeq ($(SCHEDULER), AceMesh_scheduler)
OBJECTS += task.o task_slave.o scheduler.o  scheduler_slave.o aceMesh_stack.o aceMesh_stack_slave.o ldm_privatequeue.o reg_transfer.o
endif

ifeq ($(USE_SLAVE_HELPER), true)
OBJECTS += helper_slave.o
endif

ifeq ($(PAPI_PERFORMANCE),true)
OBJECTS += aceMesh_performance.o
endif

ifneq ($(THREAD_TRACE),false)
OBJECTS += thread_trace.o thread_trace_slave.o
endif

ifeq ($(PARALLEL_LEVEL),NO_PARALLEL)
ifeq ($(CONCURRENT_CONSTRUCT_GRAPH),true)
		OBJECTS += aceMesh_concurrent_task.o  aceMesh_concurrent_task_slave.o  task_dag_graph.o task_dag_graph_slave.o  
else
		OBJECTS += aceMesh_task.o aceMesh_task_slave.o  task_dag_graph.o task_dag_graph_slave.o 
endif
#else
#OBJECTS += concurrent_aceMesh_task.o concurrent_task_dag_graph.o  
endif

#ifeq ($(MEMORY_POOL),true)
OBJECTS += MemPool.o MemPool_slave.o
#endif

DagTaskScheduler_static:  $(OBJECTS)
	ar r libdag_task_scheduler.a $(OBJECTS)
	@sed "3i $(HEAD_DEFINE)" aceMesh_runtime.h > aceMesh_runtime_install.h
	@sed "3i $(HEAD_DEFINE)" aceMesh_task.h > aceMesh_task_install.h
	@sed "3i $(HEAD_DEFINE)" aceMesh_concurrent_task.h > aceMesh_concurrent_task_install.h
	#@sed "3i $(HEAD_DEFINE)" aceMesh_hierarchy_task.h > aceMesh_hierarchy_task_install.h
	#@sed "3i $(HEAD_DEFINE)" tbb_thread_local.h > tbb_thread_local_install.h

DagTaskScheduler_dynamic: $(OBJECTS) 
	$(cc_slave)  -hybrid -fPIC -shared -o libdag_task_scheduler_static.so $(OBJECTS) 

hashtable.o:hashtable.c hashtable.h
	$(cc) $(CFLAGS) -c hashtable.c

hashtable_slave.o:hashtable_slave.c hashtable.h
	$(cc_slave) $(CFLAGS) -c hashtable_slave.c

task.o: task.c task.h 
	$(cc) $(CFLAGS) -c task.c

ci_task.o: ci_task.cpp ci_task.h
	$(cc) $(CFLAGS) -c ci_task.cpp

ci_task_slave.o: ci_task_slave.c ci_task.h
	$(cc_slave) $(CFLAGS) -c ci_task_slave.c

aceMesh_concurrent_task.o:aceMesh_concurrent_task.c aceMesh_concurrent_task.h
	$(cc) $(CFLAGS) -c aceMesh_concurrent_task.c

aceMesh_concurrent_task_slave.o:aceMesh_concurrent_task_slave.c aceMesh_concurrent_task.h
	$(cc_slave) $(CFLAGS) -msimd -c aceMesh_concurrent_task_slave.c
	
aceMesh_composite_task.o: aceMesh_composite_task.cpp aceMesh_composite_task.h
	$(CC) $(CFLAGS) -c $<

task_slave.o: task_slave.c task.h
	$(cc_slave) $(CFLAGS) -c task_slave.c

MemPool.o: MemPool.c MemPool.h
	$(cc) $(CFLAGS) -c  MemPool.c
#	$(CC) $(CFLAGS) -c  MemPool.c
MemPool_slave.o: MemPool_slave.c MemPool.h
	$(cc_slave) $(CFLAGS) -c MemPool_slave.c

thread_trace.o:thread_trace.c thread_trace.h
	$(cc) $(CFLAGS) -c thread_trace.c

thread_trace_slave.o:thread_trace_slave.c thread_trace.h
	$(cc_slave) $(CFLAGS) -c thread_trace_slave.c

aceMesh_utils_slave.o: aceMesh_utils.h aceMesh_utils_slave.c
	$(cc_slave) $(CFLAGS) -c aceMesh_utils_slave.c
aceMesh_utils.o: aceMesh_utils.h aceMesh_utils.c
	$(cc) $(CFLAGS) -c aceMesh_utils.c

acelog.o: utils/acelog.c utils/acelog.h
	$(CC) $(CFLAGS) -c  $<

affinity_id_generator.o: affinity_id_generator.h affinity_id_generator.cpp
	$(CC) $(CFLAGS) -c affinity_id_generator.cpp 

affinity_id_generator_range.o: affinity_id_generator_range.h affinity_id_generator_range.cpp
	$(CC) $(CFLAGS) -c affinity_id_generator_range.cpp 

disjoin_set.o: disjoin_set.h disjoin_set.cpp
	$(CC) $(CFLAGS) -c disjoin_set.cpp 

aceMesh_performance.o: aceMesh_performance.cpp aceMesh_performance.h
	$(CC) $(CFLAGS) -c aceMesh_performance.cpp

aceMesh_thread.o: aceMesh_thread.cpp aceMesh_thread.h 
	$(CC) $(CFLAGS) -c aceMesh_thread.cpp 


aceMesh_stack.o: aceMesh_stack.c aceMesh_stack.h  
	$(cc) $(CFLAGS) -c aceMesh_stack.c 

aceMesh_stack_slave.o: aceMesh_stack_slave.c aceMesh_stack.h
	$(cc_slave) $(CFLAGS) -msimd -c aceMesh_stack_slave.c 

dma_reuse_slave.o:dma_reuse_slave.c dma_reuse.h
	sw5cc -slave $(CFLAGS) -cpp -O3  -msimd -c dma_reuse_slave.c

scheduler.o: scheduler.c scheduler.h 
	$(cc) $(CFLAGS) -c scheduler.c

scheduler_slave.o:scheduler_slave.c scheduler.h
	$(cc_slave) $(CFLAGS) -c scheduler_slave.c

helper_slave.o: helper_slave.c
	$(cc_slave) $(CFLAGS) -c helper_slave.c

aceMesh_task.o: aceMesh_task.c $(source_aceMesh_task_h) 
	$(cc) $(CFLAGS) -c $<

aceMesh_task_slave.o: aceMesh_task.h
	$(cc_slave) $(CFLAGS) -msimd -c $(source_aceMesh_task_slave_cpp)

aceMesh_runtime.o: $(source_aceMesh_cpp) $(source_h) aceMesh_performance.h 
	$(CC) $(CFLAGS) -c $(source_aceMesh_cpp) 

task_dag_graph.o: $(source_task_dag_graph_cpp) $(source_h)  $(source_task_dag_graph_h)
	$(CC) $(CFLAGS) -c $(source_task_dag_graph_cpp)  
task_dag_graph_slave.o:task_dag_graph_slave.c task_dag_graph.h
	$(cc_slave) $(CFLAGS) -c task_dag_graph_slave.c

addr_area_manager.o: $(source_addr_area_manager_h) $(source_addr_area_manager_cpp)
	$(CC) $(CFLAGS) -c $(source_addr_area_manager_cpp)

dag_graph_check.o: $(source_dag_graph_check_h) $(source_h) 
	$(CC) $(CFLAGS) -c  $(source_dag_graph_check_cpp)

trace_out_slave.o: trace_out_slave.c aceMesh_runtime.h
	$(cc_slave) $(CFLAGS) -c trace_out_slave.c
	
ldm_privatequeue.o: ldm_privatequeue.c reg_transfer.h
	$(cc_slave) $(CFLAGS) -c ldm_privatequeue.c

reg_transfer.o: reg_transfer.c reg_transfer.h task.h
	$(cc_slave) $(CFLAGS) -c -msimd reg_transfer.c

ifeq ($(SCHEDULER), AceMesh_scheduler)
aceMesh_scheduler_init.o: aceMesh_scheduler_init_v2.cpp aceMesh_scheduler_init_v2.h scheduler.h
	$(CC) $(CFLAGS) -c aceMesh_scheduler_init_v2.cpp -o aceMesh_scheduler_init.o
endif

aceMesh_clang.o: aceMesh_clang.cpp
	$(CC) $(CFLAGS) $(LIBFLAGS) -c aceMesh_clang.cpp -o aceMesh_clang.o
aceMesh_clang_slave.o: aceMesh_clang_slave.c
	$(cc_slave) $(CFLAGS) $(LIBFLAGS) -c aceMesh_clang_slave.c
clean:
	-rm -f *.o > /dev/null 2>&1
	-rm -f *.a > /dev/null 2>&1
	-rm -f *.so > /dev/null 2>&1
	-rm -f *_install.h > /dev/null 2>&1
